package org.dingyom.basics.service.impl;

import org.dingyom.basics.service.IFastDfsService;
import org.dingyom.basics.util.FastdfsUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
public class FastDfsServiceImpl implements IFastDfsService {
    @Value("${fastDfs.url}")
    private String portUrl;
    @Override
    public String upload(byte[] file, String extName) {
        return portUrl+FastdfsUtil.upload(file, extName);
    }

    @Override
    public void delete(String path) {
        path = path.substring(portUrl.length());
        FastdfsUtil.delete(path);
    }

    /*public static void main(String[] args) {
        String path = "http://115.159.217.249:8888/group1/M00/00/00/rBEAA2MVpLuAdn4yAAWJ4_buT14913.jpg";
        path = path.substring("http://115.159.217.249:8888".length());
        System.out.println(path);
    }*/
}
